Imports amod2
Imports formulare

Public Class Form1

    Private main As Main ' hlavna triada z ktorej sa volaju vsetky ostatne metody 


    Private Sub btn_testDatasetFrm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_testDatasetFrm.Click
        'main.FrmDataset.ShowDialog()
    End Sub

    Private Sub btn_DBGenSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_DBGenSettings.Click
        Dim DlgDBGen As New DlgDBGenerator()
        If (main.DBGeneratorSettings IsNot Nothing) Then    ' ak eksistuje uz nastavenie
            DlgDBGen.SetComponents(main.DBGeneratorSettings)
        End If
        DlgDBGen.giveData(main) ' prerobit na konstruktor 
        DlgDBGen.ShowDialog()


    End Sub

    Private Sub btn_DB_beg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_DB_beg.Click
        ' main.generateDatabase()
    End Sub

    Private Sub btn_createDBonDisk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_createDBonDisk.Click
        'main.createDatabaseOnDisk()
    End Sub

    Private Sub btn_createSolution_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub
    ' pri generovani projektu sa spusti len telo tejto metody : konstruktor a metoda GenerateProject
    Private Sub btn_final_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_final.Click

        ' nacitanie Amod Soulution iba pre testovanie
        Dim lDsAmodSolution As New DsAmodSolution()
        lDsAmodSolution.ReadXml(txtPouziteSolution.Text, XmlReadMode.IgnoreSchema)

        '"E:\templateWorks\Templates"
        'dan Me.main = New Main("Mod", "Projekt", "E:\templateWorks\Templates", Nothing, "E:\templateWorks\destination", "Projekt")
        Dim frmFormulareExport As FrmWizardNastavenia = New FrmWizardNastavenia(New GeneratorFormularov(txtCestaKTemplatom.Text, New Dat("", "", "")), txtZoznamovyFormular.Text, txtFrmNastavenia.Text)
        frmFormulareExport.ShowDialog()
        Dim lExportSettings = frmFormulareExport.ExportSettings
        'Me.main = New Main(txtCestaKTemplatom.Text, Nothing, "E:\zuzka5", "projekt_8", lExportSettings)
        Me.main = New Main(txtCestaKTemplatom.Text, Nothing, txtPathDestination.Text, txtProjectName.Text, lExportSettings)
        '***volanie metody
        Try
            Dim modules As New List(Of ModulAtributes)
            modules = main.getModulesListForGenerating(lDsAmodSolution)

            Me.main.GenerateProject(modules, modules, "")
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub


    Private Sub btn_createOneFrmProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_createOneFrmProject.Click

        'tmp premenne
        Dim version As String = "Description"
        Dim modulHuman As String = "ModulPartner"
        Dim modulName As String = "ModulPartner"
        Dim unitName As String = "FORMULAROsoby"
        Dim pathAmodProj As String = "E:\zuzka5\projekt_8.aModProj"
        Dim pathRootTemplate As String = "E:\templateWorks\Templates"
        Dim pathDest As String = "E:\zuzka5"
        Dim projectName As String = "projekt_8"

        Dim lDsAmodSolution As New DsAmodSolution()
        lDsAmodSolution.ReadXml(pathAmodProj, XmlReadMode.IgnoreSchema)

        '***konstruktor
        Dim frmFormulareExport As FrmWizardNastavenia = New FrmWizardNastavenia(New GeneratorFormularov(txtCestaKTemplatom.Text, New Dat("", "", "")), txtZoznamovyFormular.Text, txtFrmNastavenia.Text)
        frmFormulareExport.ShowDialog()
        Dim lExportSettings = frmFormulareExport.ExportSettings
        Me.main = New Main(pathRootTemplate, Nothing, pathDest, projectName, lExportSettings)

        Dim modulPath As String
        modulPath = main.getModulesForGenerating(lDsAmodSolution)(modulName)
        '***volanie metody

        Try
            Dim modules As New List(Of ModulAtributes)
            modules = main.getModulesListForGenerating(lDsAmodSolution)

            Me.main.GenerateOneFormProject(modules, modulName, modulHuman, version, modulPath, unitName)
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pathAmodProj As String = "E:\zuzka5\projekt_8.aModProj"
        Dim pathDest As String = "E:\zuzka5"
        Dim lDsAmodSolution As New DsAmodSolution()
        lDsAmodSolution.ReadXml(pathAmodProj, XmlReadMode.IgnoreSchema)

        Dim frmFormulareExport As FrmWizardNastavenia = New FrmWizardNastavenia(New GeneratorFormularov(txtCestaKTemplatom.Text, New Dat("", "", "")), txtZoznamovyFormular.Text, txtFrmNastavenia.Text)
        frmFormulareExport.ShowDialog()
        Dim lExportSettings = frmFormulareExport.ExportSettings

        main = New Main(Nothing, pathDest, lExportSettings)
        Dim modules As New List(Of ModulAtributes)
        modules = main.getModulesListForGenerating(lDsAmodSolution)
        modules.RemoveRange(1, 1)
        main.generateDB(modules)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pathAmodProj As String = "E:\zuzka5\projekt_8.aModProj"
        Dim pathDest As String = "E:\zuzka5"
        Dim lDsAmodSolution As New DsAmodSolution()
        lDsAmodSolution.ReadXml(pathAmodProj, XmlReadMode.IgnoreSchema)


        Dim frmFormulareExport As FrmWizardNastavenia = New FrmWizardNastavenia(New GeneratorFormularov(txtCestaKTemplatom.Text, New Dat("", "", "")), txtZoznamovyFormular.Text, txtFrmNastavenia.Text)
        frmFormulareExport.ShowDialog()
        Dim lExportSettings = frmFormulareExport.ExportSettings

        main = New Main(Nothing, pathDest, lExportSettings)
        Dim modules As New List(Of ModulAtributes)
        modules = main.getModulesListForGenerating(lDsAmodSolution)


        main.generateDB(modules)
    End Sub
End Class
